/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Threads;

/**
 *
 * @author Luis_Angel
 */
public class TestCurrentThread {

    static class Cliente extends Thread {

        public void run() {
            for (int i = 0; i < 10; i++) {
                Recurso.uso();
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
            }

            }
           
        }

        ;
    }

    public static void main(String[] args) throws Exception {
        Cliente juan = new Cliente();
        juan.setName("Juan López");
        Cliente ines = new Cliente();
        ines.setName("Inés García");
        juan.start();
        ines.start();
    }
}

class Recurso {

    static synchronized void uso() {
        Thread t = Thread.currentThread();
        System.out.println("Soy " + t.getName());
    }
}

